<?php
include_once( DIR_CLASS . 'lib/smarty/Smarty.class.php' );
class View
{
	public static function getInstance()
	{
		if ( !isset ( self::$instance ) )
		{
			self::$instance = new View();
		}
		return self::$instance;

	}

	private function __construct()
	{
		$this->tpl = new Smarty();
		$this->tpl->left_delimiter = "<{";
		$this->tpl->right_delimiter= "}>";
		$this->tpl->template_dir   = DIR_VIEW;
		$this->tpl->cache_dir      = DIR_CACHE;
		$this->tpl->compile_dir    = DIR_TEMPLATE;
	}
	public function __destruct()
	{
	}
	private function __clone()
	{
		trigger_error( 'System Error!', E_USER_ERROR );
	}
	
	public function assign( $tpl ){
		$this->tpl->assign( $tpl );	
	}
	
	public function display( $tplFile ){
		$suffix = defined ( 'SYS_TEMPLATE_SUFFIX' )? SYS_TEMPLATE_SUFFIX : '.view.html';
		$this->tpl->display(  $tplFile.$suffix );
	}
	private static $instance;
	private $tpl;
}